/**
 * 
 */
package com.bitantenna.player;

import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import com.bitantenna.Spot;



public final class PlayerCloseListener implements WindowListener {
	private final Spot spot;

	public PlayerCloseListener(Spot spot) {
		this.spot = spot;
	}

	@Override
	public void windowOpened(WindowEvent e) {
		
	}

	@Override
	public void windowIconified(WindowEvent e) {
	}

	@Override
	public void windowDeiconified(WindowEvent e) {
	}

	@Override
	public void windowDeactivated(WindowEvent e) {
	}

	@Override
	public void windowClosing(WindowEvent e) {
		if (spot.status()!=Spot.Status.stopped) {
			spot.stopListen();
			System.out.println("stopping spot.");
		}
	}

	@Override
	public void windowClosed(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowActivated(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}
}